<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ include file="/jsp/common/common.jsp"%>  

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/js/common.js"/>"></script>
<script>
	function initList(listDisplayEId) {
		$('#' + listDisplayEId)
				.datagrid(
						{
							url : "<c:url value='/shop/shopRaiseList.do'/>"
									+ "?shopId=" + "${shopVo.shopId }",
							nowrap : false,
							striped : true,
							collapsible : true,
							remoteSort : true,
							notSelectByRow : false,
							toolbar : [
									{
										id : listDisplayEId + '_btn_add',
										text : '新增',
										iconCls : 'icon-add',
										handler : function() {
											
												var new_win = window
														.open(
																"<c:url value='/jsp/openIndexSun2.jsp?url=/shop/preSaveShopRaise.do'/>"
																		+ "?shopId="
																		+ "${shopVo.shopId }",
																"sun2",
																"width=1200px,height=600px,status=no,scrollbars=yes");
												new_win.focus();
												$('#' + listDisplayEId)
														.datagrid('reload');
										}	
									},
									'-',
									{
										id : listDisplayEId + '_btn_edit',
										text : '修改',
										iconCls : 'icon-edit',
										handler : function() {

											var row = $('#' + listDisplayEId)
													.datagrid('getSelections');
											if (row.length == 0) {
												$.messager.alert('提示',
														'请选择一条记录操作！', 'info');
												return;
											} else {
												var new_win = window
														.open(
																"<c:url value='/jsp/openIndexSun2.jsp?url=/shop/preUpdateShopRaise.do'/>"
																		+ "?rpid="
																		+ row[0]['rpid'] + "&shopId=" + row[0]['shopId'],
																"sun2",
																"width=1200px,height=600px,status=no,scrollbars=yes");
												new_win.focus();
												$('#' + listDisplayEId)
														.datagrid('reload');
											}
											$('#' + listDisplayEId).datagrid(
													'clearSelections');
										}
									},
                                    '-',
                                    {
                                        id : listDisplayEId + '_btn_delete',
                                        text : '删除',
                                        iconCls : 'icon-cancel',
                                        handler : function() {

                                            var row = $('#' + listDisplayEId)
                                                    .datagrid('getSelections');
                                            if (row.length == 0) {
                                                $.messager.alert('提示',
                                                        '请选择一条记录操作！', 'info');
                                                return;
                                            } else {
                                            	var str = "rpid=" + row[0]['rpid']; 
                                                $.messager.confirm('提示', '是否删除该条记录？', function(r){
                                                    if (r){         
                                                        $.ajax({type:'post',url:"<c:url value='/shop/deleteShopRaise.do'/>",data:str,dataType:"json",//设置查询参数及提交路径
                                                        success:function(data){
                                                            if(data.success){
                                                                $.messager.alert("提示", "删除成功！", 'info');
                                                                $('#'+listDisplayEId).datagrid('reload');
                                                            }else{
                                                                $.messager.alert("提示", data.msg, 'warning');
                                                            }
                                                        },
                                                        error:function(){
                                                            $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
                                                        }
                                                    });
                                                }
                                                $('#'+listDisplayEId).datagrid('reload');
                                                $('#'+listDisplayEId).datagrid('clearSelections');
                                                });
                                            }
                                            $('#' + listDisplayEId).datagrid(
                                                    'clearSelections');
                                        }
                                    } ],
							onLoadError : function() {
								$.messager.alert('错误', '获取数据失败，请与管理员联系！',
										'error');
							},
							onClickRow : function(rowIndex) {
								$(".myrad").prop("checked", false);
								$(".myrad").eq(rowIndex).prop("checked", true);
							}
						});
	};
	$(document).ready(function() {
		initList('listDisplay');

	});
	function formatRadio(value, rowData, rowIndex) {
		return value = "<input type='radio' class='myrad'  name='radioStore' />";
	}
	$(function() {
		$('#materType').combobox({
			url : "<c:url value='/mater/pulldownMaterType.do?space=1'/>",
			editable : true, //不可编辑状态  
			cache : false,
			panelHeight : '150',
			valueField : 'materType',
			textField : 'materTypename',
		});
	});
</script>
</head>
<body>
	<table width="98%">
		<tr>
			<td>
				<div
					style="height: auto; width: 1180px; background: #fafafa; padding: 5px;"
					class="easyui-panel" title="查询" iconCls="icon-search"
					collapsible="true" minimizable="false" maximizable="false"
					closable="false">
					<form id="searchForm" name="searchForm" method="post"
						action="userlist.txt"
						onsubmit="return searchDGData(this.id,'listDisplay');">
						<div>
							<table cellpadding="5">
								<tr>
									<td>商店名：</td>
									<td><input class="easyui-validatebox" id="shopName" readOnly="true"
										editable="true" name="shopName" value="${shopVo.shopName }"></input></td>
									<td>类别：</td>
									<td><input class="easyui-combobox" id="materType"
										editable="false" name="materType"></input></td>
									<td><input type="button" onclick="searchInfo()" value="查询"></td>
								</tr>
							</table>
						</div>
					</form>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<table id="listDisplay" title="机构列表" iconCls="icon-list"
					singleSelect="true" idField="rpid" loadMsg="请稍候......"
					pagination="true" pageSize="20" pageList="[10,20,30,40,50]"
					sortName="shopId" rownumbers="true" sortOrder="asc">
					<thead>
						<tr>
							<th field="materRole" width="25" align="center"
								formatter="formatRadio"></th>
							<th field="rpid" width="40" sortable="true" editor="text"
								hidden="true"></th>
							<th field="shopId" width="70" sortable="true" editor="text">店铺id</th>
							<th field="shopName" width="140" sortable="true">店铺名称</th>
							<th field="supId" width="70" sortable="true">供货商id</th>
							<th field="supName" width="120" sortable="true">供货商名称</th>
							<th field="materType" formatter="formatFoodType1" width="70" sortable="true">种类id</th>
							<th field="materTypeName" width="70" sortable="true"
								hidden="true">种类</th>
							<th field="raiseAmount" width="100" sortable="true">抬价百分比</th>
						</tr>
					</thead>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>